package com.shop.mall.utils;

import java.util.ArrayList;
import java.util.List;

/**
 * 分页
 *
 * @author admin
 */
public class Pages {


    // 第一页的页码
    private int firstPageNum = 1;

    // 上一页的页码
    private int upPageNum;

    // 下一页页码
    private int nextPageNum;

    // 末页页码
    private int endPageNum;

    // 总页数
    private int totalPage;

    // 总条数
    private int totalRecord;

    public Pages() {

    }

    public Pages(int currentPage, int totalRecord, int totalPage, List list) {
        this.currentPage = currentPage;
        this.totalRecord = totalRecord;
        this.totalPage = totalPage;
        this.list = list;

        /**
         * 设置上一页
         */
        /*if (currentPage == 1) {
            upPageNum = 1;
        } else {
            upPageNum = currentPage - 1;
        }*/
        /**
         * 设置下一页
         */
        /*if (currentPage == totalPage) {
            nextPageNum = totalPage;
        } else {
            nextPageNum = currentPage + 1;
        }*/

        this.setEndPageNum(totalPage);

    }

    public int getTotalRecord() {
        return totalRecord;
    }

    public void setTotalRecord(int totalRecord) {
        this.totalRecord = totalRecord;
    }

    //当前页
    private int currentPage;

    public int getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(int currentPage) {
        this.currentPage = currentPage;
    }

    public int getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }

    private List list = new ArrayList();

    public int getFirstPageNum() {
        return firstPageNum;
    }

    public void setFirstPageNum(int firstPageNum) {
        this.firstPageNum = firstPageNum;
    }

    public int getUpPageNum() {
        if (currentPage == 1) {
            upPageNum = 1;
        } else {
            upPageNum = currentPage - 1;
        }
        return upPageNum;
    }

    public void setUpPageNum(int upPageNum) {
        this.upPageNum = upPageNum;
    }

    public int getNextPageNum() {
        if (currentPage == totalPage) {
            nextPageNum = totalPage;
        } else {
            nextPageNum = currentPage + 1;
        }
        return nextPageNum;
    }

    public void setNextPageNum(int nextPageNum) {
        this.nextPageNum = nextPageNum;
    }

    public int getEndPageNum() {
        return endPageNum=totalPage;
    }

    public void setEndPageNum(int endPageNum) {
        this.endPageNum = endPageNum;
    }

    public List getList() {
        return list;
    }

    public void setList(List list) {
        this.list = list;
    }

}
